using System.Collections;
using Anvil.Core;

namespace Anvil.Core.Commands
{
    /// <summary>
    /// Execute database statement indicated by QueryID 
    /// and wrap result in KeyValue objects 
    /// so that lists can be displayed by standard methods.
    /// </summary>
    /// 
    public class BaseFilterList : BaseMapper
    {
        public override bool RequestExecute(IRequestContext context)
        {
            IList rows = Mapper.QueryForList(QueryID, null);
            IKeyValueList list = new KeyValueList();
            foreach (object key in rows)
            {
                list.Add(new KeyValue(key.ToString(), key));
            }
            context[ID] = list;
            return CONTINUE;
        }
    }
}